package com.snifferx.managedbeans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import com.snifferx.domain.AuthorityEntity;
import com.snifferx.domain.UserEntity;

@ManagedBean(name = "testSelectBean")
@SessionScoped
public class TestSelectBean implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// test roleShow
	private Map<String, AuthorityEntity> allRoles;
	private List<AuthorityEntity> roleList = new ArrayList<AuthorityEntity>();

	public TestSelectBean() {
		super();
		allRoles = new HashMap<String, AuthorityEntity>();
		AuthorityEntity ADMINISTRATOR = new AuthorityEntity(1, "ROLE_ADMINISTRATOR");
		AuthorityEntity USER = new AuthorityEntity(1, "ROLE_USER");
		AuthorityEntity GUEST = new AuthorityEntity(1, "ROLE_GUEST");
		AuthorityEntity VIEW = new AuthorityEntity(1, "ROLE_VIEW");
		
		
		allRoles.put("ADMINISTRATOR", ADMINISTRATOR);
		allRoles.put("USER", USER);
		allRoles.put("GUEST", GUEST);
		allRoles.put("VIEW", VIEW);

		roleList.add(USER);
	}

	public Map<String, AuthorityEntity> getAllRoles() {
		return allRoles;
	}

	public void setAllRoles(Map<String, AuthorityEntity> allRoles) {
		this.allRoles = allRoles;
	}

	public String doUpdate() {
		// update userInfo to DB
		return null;
	}

	public List<AuthorityEntity> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<AuthorityEntity> roleList) {
		this.roleList = roleList;
	}

}
